<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>getByClass</title>
   <script>
     function getByClass(oParent,sClass){
	     var aResult=[];
	     var aEle=oParent.getElementsByTagName("*");
		 for(var i=0;i<aEle.length;i++){
		  if(aEle[i].className==sClass){
		     aResult.push(aEle[i]);
		  }
		 }
		 return aResult;
	 }
   
     window.onload=function(){
	    var oUl=document.getElementById("ul1");
	    var aBox=getByClass(oUl,"box");
		for(var i=0;i<aBox.length;i++){
		   aBox[i].style.background="blue ";
		}
	 };
   </script>
</head>
<body>
  <ul id="ul1">
     <li class="box"></li>
	 <li></li>
	 <li class="box"></li>
	 <li></li>
	 <li class="box"></li>
	 
  
  
  </ul>
</body>
</html>